package com.xixi.core.rpc.protocol;

import lombok.Getter;

/**
 * @author: zxh
 * @date: 2024/8/26 9:55
 * @description: 协议消息的状态枚举
 */
@Getter
public enum ProtocolMessageStatusEnum {

	OK("ok", 20),
	BAD_REQUEST("badRequest", 40),
	BAD_RESPONSE("badResponse", 50);


	private final String text;

	private final int value;

	ProtocolMessageStatusEnum(String text, int value) {
		this.text = text;
		this.value = value;
	}

	/**
	 * 根据value获取枚举值
	 * @param value 信息码
	 * @return 返回枚举值
	 */
	public static ProtocolMessageStatusEnum getEnumByValue(int value) {
		for (ProtocolMessageStatusEnum anEnum : ProtocolMessageStatusEnum.values()) {
			if (anEnum.value == value) {
				return anEnum;
			}
		}
		return null;
	}
}
